<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
</head>
<body>

<div style="width: 650px; position: relative; left:25%;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
      <legend>表单集合练习</legend>
    </fieldset>
{#    <form class="layui-form" action="">#}
    <form class="layui-form layui-form-pane" action="/get_mas/" method="post">  {# 方框风格的表单集合 #}
      {% csrf_token %}
        <div class="layui-form-item">
        <label class="layui-form-label layui-bg-red">标题</label>
        <div class="layui-input-block">
          <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
        </div>
      </div>

      <div class="layui-form-item">
        <label class="layui-form-label layui-bg-blue">用户名</label>
        <div class="layui-input-block">
          <input type="text" name="username" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
      </div>

      <div class="layui-form-item">
        <div class="layui-inline">
          <label class="layui-form-label layui-bg-orange">手机号码</label>
          <div class="layui-input-inline">
            <input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input">
          </div>
        </div>

        <div class="layui-inline">
          <label class="layui-form-label layui-bg-orange">邮箱地址</label>
          <div class="layui-input-inline">
            <input type="text" name="email" lay-verify="email" autocomplete="off" class="layui-input">
          </div>
        </div>
      </div>
      <div class="layui-form-item" align="center">
        <div class="layui-input-block">
          <button class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="demo1">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-danger layui-btn-radius">重置</button>
        </div>
      </div>
    </form>
</div>

<script src="{% static  "lib/layui/layui.js" %}" charset="utf-8"></script>

<script>
    layui.use('form', function(){
      var form = layui.form;
      //自定义验证规则
      form.verify({
        title: function(value){
          if(value.length < 5){
            return '标题至少得5个字符啊';
          }
        }
      });
    });
</script>

</body>
</html>
